package com.zhuang.designpattern.strategy;

import com.zhuang.designpattern.strategy.impl.MJCouponDiscount;
import com.zhuang.designpattern.strategy.impl.NYGCouponDiscount;
import com.zhuang.designpattern.strategy.impl.ZJCouponDiscount;
import com.zhuang.designpattern.strategy.impl.ZKCouponDiscount;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

/**
 * description: Test
 * date: 2022/9/21 17:44
 * author: Zhuang
 * version: 1.0
 */
public class Test {
    public static void main(String[] args) {
        Logger logger = LoggerFactory.getLogger(Test.class);

        // 直减；100-10，商品100元
        Context<Double> context1 = new Context<>(new ZJCouponDiscount());
        BigDecimal discountAmount1 = context1.discountAmount(10D, new BigDecimal(100));
        logger.info("测试结果：直减优惠后金额 {}", discountAmount1);


        // 满100减10，商品100元
        Context<Map<String, String>> context2 = new Context<>(new MJCouponDiscount());
        Map<String, String> mapReq = new HashMap<>();
        mapReq.put("x", "100");
        mapReq.put("n", "10");
        BigDecimal discountAmount2 = context2.discountAmount(mapReq, new BigDecimal(100));
        logger.info("测试结果：满减优惠后金额 {}", discountAmount2);


        // 折扣9折，商品100元
        Context<Double> context3 = new Context<>(new ZKCouponDiscount());
        BigDecimal discountAmount3 = context3.discountAmount(0.9D, new BigDecimal(100));
        logger.info("测试结果：折扣9折后金额 {}", discountAmount3);


        // n元购；100-10，商品100元
        Context<Double> context4 = new Context<>(new NYGCouponDiscount());
        BigDecimal discountAmount4 = context4.discountAmount(90D, new BigDecimal(100));
        logger.info("测试结果：n元购优惠后金额 {}", discountAmount4);
    }
}
